package com.wanshi.servlet;

import com.alibaba.fastjson.JSON;
import com.wanshi.dao.AreaDao;
import com.wanshi.entity.Xian;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/AreaServlet")
public class AreaServlet extends HttpServlet {

    private AreaDao areaDao = new AreaDao();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String cityid = request.getParameter("cityid");

        List<Xian> xians = areaDao.getXians(cityid);

        response.getWriter().write(  JSON.toJSONString(xians) );
    }
}
